# -*- coding: utf-8 -*-
# Version:python3.7
from odoo import fields,models,api,exceptions

class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'
    user_default_password =fields.Char('系统默认密码', help=u"设置默认密码")
    system_name = fields.Char('系统名称', help=u"设置自己的系统名称")
    is_employee = fields.Boolean('是否创建职员')
    #     agriapp_research_platform_group_operator
    # group_use_lead = fields.Boolean(string="Leads", implied_group='crm.group_use_lead')

    # group_book_report_operator = fields.Boolean(string="著作报告权限", related='agri_group',
    #                                                   implied_group='agriapp.agriapp_book_report_group_operator')
    # group_crop_variety_operator = fields.Boolean(string="作物品种权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_crop_variety_right_group_operator')
    # group_invention_patent_operator = fields.Boolean(string="发明专利权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_invention_patent_group_operator')
    # group_journal_article_operator = fields.Boolean(string="期刊论文权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_journal_article_group_operator')
    # group_new_product_operator = fields.Boolean(string="新型品种权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_new_product_group_operator')
    # group_research_achievement_operator = fields.Boolean(string="科研成果权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_research_achievement_group_operator')
    # group_research_platform_operator = fields.Boolean(string="科研平台权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_research_platform_group_operator')
    # group_research_project_operator = fields.Boolean(string="科研项目权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_research_project_group_operator')
    # group_software_copyright_operator = fields.Boolean(string="软件著作权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_software_copyright_group_operator')
    # group_standard_operator = fields.Boolean(string="标准权限", related='agri_group',
    #                                                  implied_group='agriapp.agriapp_standard_group_operator')
    # agri_group = fields.Boolean(string="科研管理操作员权限")



    @api.model
    def get_values(self):
        res = super(ResConfigSettings, self).get_values()
        ir_config = self.env['ir.config_parameter'].sudo()
        system_name = ir_config.get_param('system_name', default='管理系统')
        user_default_password = ir_config.get_param('user_default_password', default='123456')
        is_employee =ir_config.get_param('is_employee')
        agri_group = ir_config.get_param('agri_group')
        # group_research_platform_operator = ir_config.get_param('group_research_platform_operator') , agri_group=agri_group
        res.update(user_default_password=user_default_password,system_name=system_name,is_employee=is_employee)
        return res

    def set_values(self):
        # super(ResConfigSettings, self).set_values()
        ir_config = self.env['ir.config_parameter'].sudo()
        ir_config.set_param("system_name", self.system_name or "")
        ir_config.set_param("user_default_password", self.user_default_password or "")
        ir_config.set_param("is_employee", self.is_employee )
        # ir_config.set_param("agri_group", self.agri_group)
        # ir_config.set_param('group_research_platform_operator',self.group_research_platform_operator)
        super(ResConfigSettings, self).set_values()


